static char
-osm_feature_ikey(const char* key)
+osm_feature_ikey(const QString& key)
{
- return keys.value(QString::fromUtf8(key), -1);
+ return keys.value(key, -1);
}
return strip_html(&utf); // util.cc
}
+static char*
+osm_strip_html(const QString& str)
+{
+ return osm_strip_html(CSTR(str));
+}
+
static void
osm_node_end(xg_string args, const QXmlStreamAttributes*)
if (attrv->hasAttribute("id")) {
QString atstr = attrv->value("id").toString();
-
- xasprintf(&wpt->description, "osm-id %s", CSTR(atstr));
+ wpt->description = "osm-id " + atstr;
if (waypoints.contains(atstr)) {
warning(MYNAME ": Duplicate osm-id %s!\n", CSTR(atstr));
} else {
}
if (attrv->hasAttribute("timestamp")) {
- QByteArray tsutf8 = attrv->value("timestamp").toString().toUtf8();
- wpt->creation_time = xml_parse_time(tsutf8.constData());
+ QString ts = attrv->value("timestamp").toString();
+ wpt->creation_time = xml_parse_time(ts);
}
}
static void
osm_node_tag(xg_string args, const QXmlStreamAttributes* attrv)
{
- QByteArray qkey, qvalue;
- const char* key = "", *value = "";
+ QString key, value;
char* str;
signed char ikey;
if (attrv->hasAttribute("k")) {
- qkey = attrv->value("k").toString().toUtf8();
- key = qkey.constData();
+ key = attrv->value("k").toString();
}
if (attrv->hasAttribute("v")) {
- qvalue = attrv->value("v").toString().toUtf8();
- value = qvalue.constData();
+ value = attrv->value("v").toString();
}
str = osm_strip_html(value);
- if (strcmp(key, "name") == 0) {
+ if (key == QLatin1String("name")) {
if (wpt->shortname.isEmpty()) {
wpt->shortname = str;
}
- } else if (strcmp(key, "name:en") == 0) {
+ } else if (key == QLatin1String("name:en")) {
wpt->shortname = str;
} else if ((ikey = osm_feature_ikey(key)) >= 0) {
- wpt->icon_descr = osm_feature_symbol(ikey, value);
- } else if (strcmp(key, "note") == 0) {
+ wpt->icon_descr = osm_feature_symbol(ikey, CSTR(value));
+ } else if (key == QLatin1String("note")) {
if (wpt->notes.isEmpty()) {
wpt->notes = str;
} else {
wpt->notes += "; ";
wpt->notes += str;
}
- } else if (strcmp(key, "gps:hdop") == 0) {
+ } else if (key == QLatin1String("gps:hdop")) {
wpt->hdop = atof(str);
- } else if (strcmp(key, "gps:vdop") == 0) {
+ } else if (key == QLatin1String("gps:vdop")) {
wpt->vdop = atof(str);
- } else if (strcmp(key, "gps:pdop") == 0) {
+ } else if (key == QLatin1String("gps:pdop")) {
wpt->pdop = atof(str);
- } else if (strcmp(key, "gps:sat") == 0) {
+ } else if (key == QLatin1String("gps:sat")) {
wpt->sat = atoi(str);
- } else if (strcmp(key, "gps:fix") == 0) {
+ } else if (key == QLatin1String("gps:fix")) {
if (strcmp(str, "2d") == 0) {
wpt->fix = fix_2d;
} else if (strcmp(str, "3d") == 0) {
wpt->fix = fix_none;
}
}
-
- xfree(str);
}
osm_way(xg_string args, const QXmlStreamAttributes* attrv)
{
rte = route_head_alloc();
-
if (attrv->hasAttribute("id")) {
- xasprintf(&rte->rte_desc, "osm-id %s",
- attrv->value("id").toString().toUtf8().constData());
+ rte->rte_desc = "osm-id " + attrv->value("id").toString();
}
}
static void
osm_way_tag(xg_string args, const QXmlStreamAttributes* attrv)
{
- QByteArray qkey, qvalue;
- const char* key = "", *value = "";
- char* str;
+ QString key, value;
+ QString str;
if (attrv->hasAttribute("k")) {
- qkey = attrv->value("k").toString().toUtf8();
- key = qkey.constData();
+ key = attrv->value("k").toString();
}
if (attrv->hasAttribute("v")) {
- qvalue = attrv->value("v").toString().toUtf8();
- value = qvalue.constData();
+ value = attrv->value("v").toString();
}
str = osm_strip_html(value);
- if (strcmp(key, "name") == 0) {
+ if (key == QLatin1String("name")) {
if (rte->rte_name.isEmpty()) {
rte->rte_name = str;
}
- } else if (strcmp(key, "name:en") == 0) {
+ } else if (key == QLatin1String("name:en")) {
rte->rte_name = str;
}
-
- xfree(str);
}
static void
return result;
}
+// This appears to be only for subtitles so it's OK if we "wrap"
+// times across a midnight boundary.
static void
-subrip_write_duration(QTime starttime, QTime endtime)
+subrip_write_duration(QDateTime startdtime, QDateTime enddtime)
{
+ QTime starttime = startdtime.time();
+ QTime endtime = enddtime.time();
+
/* Writes start and end time for subtitle display to file. */
gbfprintf(fout, "%02d:%02d:%02d,%03d --> ", starttime.hour(), starttime.minute(), starttime.second(), starttime.msec());
/* Now that we have the next waypoint, we can write out the subtitle for
* the previous one.
*/
- QDateTime starttime;
- QDateTime endtime;
- char *c;
/* If this condition is not true, the waypoint is before the beginning of
* the video and will be ignored
*/
- if (prevwpp->GetCreationTime().toTime_t() < time_offset)
- return;
- starttime = gps_to_video_time(prevwpp->GetCreationTime());
+ if (prevwpp->GetCreationTime().toTime_t() < time_offset) {
+ return;
+ }
+
+ QDateTime starttime = gps_to_video_time(prevwpp->GetCreationTime());
+ QDateTime endtime;
+
if (!waypointp) {
endtime = starttime.addSecs(1);
} else {
}
gbfprintf(fout, "%d\n", stnum);
stnum++;
- subrip_write_duration(starttime.time(), endtime.time());
+ subrip_write_duration(starttime, endtime);
- for (c = opt_format; *c != '\0' ; c++) {
+ for (char* c = opt_format; *c != '\0' ; c++) {
char fmt;
switch (*c) {
break;
case 't':
{
- QTime t = prevwpp->GetCreationTime().time();
+ QTime t = prevwpp->GetCreationTime().time();
gbfprintf(fout, "%02d:%02d:%02d", t.hour(), t.minute(), t.second());
break;
}